﻿using System;
using System.Collections;

using BizElements.Core;

namespace BizElements.BusinessLayer
{
    /// <summary>Serializes and deserializes entity primary keys into and from strings.</summary>
    public interface IPrimaryKeySerializer
    {
        #region Methods.

        /// <summary>Extracts and serializes the specified entity's primary key.</summary>
        /// <param name="entity">Entity whose primary key is to be serialized.</param>
        /// <returns>Serialized primary key.</returns>
        string Serialize(IEntity entity);

        /// <summary>Extracts and serializes primary key of all entities in the specified collection.</summary>
        /// <param name="entities">Entities whose primary key are to be serialized.</param>
        /// <returns>Array of serialized primary keys.</returns>
        string[] Serialize(IEnumerable entities);

        /// <summary>Parses primary key from the specified string and sets the provided entity's primary key properties.</summary>
        /// <param name="entity">Entity whose primary key properties are to be deserialized and set.</param>
        /// <param name="serializedPrimaryKey">Serialized primary key.</param>
        void Deserialize(IEntity entity, string serializedPrimaryKey);

        ///// <summary>Parses primary keys from the specified strings and sets primary key properties for all provided entities.</summary>
        ///// <param name="entities">Entity whose primary key are to be deserialized and set.</param>
        ///// <param name="serializedPrimaryKeys">Serialized primary keys.</param>
        //void Deserialize(IEntityCollection entities, string[] serializedPrimaryKeys);

        #endregion
    }
}
